package adapterfacade.test;

import adapterfacade.base.BaseSimpleDuck;
import adapterfacade.base.BaseTurkey;
import adapterfacade.impl.MallardDuckImpl;
import adapterfacade.impl.TurkeyAdapter;
import adapterfacade.impl.WildTurkey;


/**
 * 测试适配器
 * @author yaojianfeng
 */
public class DuckTestDrive {
    public static void main(String[] args) {
        //先创建一只鸭子和一只火鸡
        BaseSimpleDuck duck = new MallardDuckImpl();
        BaseTurkey turkey = new WildTurkey();

        //然后将火鸡包装进适配器中,使它看起来像只鸭子
        BaseSimpleDuck turkeyAdapter = new TurkeyAdapter(turkey);
        turkey.fly();
        turkey.gobble();
        System.out.println("========上面是火鸡==========");
        System.out.println("========下面是鸭子==========");
        test(duck);
        System.out.println("========下面是伪装成鸭子的火鸡========");
        test(turkeyAdapter);




    }

    public static void test(BaseSimpleDuck object){
        object.fly();
        object.quack();
    }
}
